package org.javaforever.gatescore.widgets;

import java.util.ArrayList;
import java.util.List;

import org.javaforever.gatescore.core.FrontDomain;
import org.javaforever.gatescore.core.Statement;
import org.javaforever.gatescore.core.StatementList;
import org.javaforever.gatescore.core.Writeable;
import org.javaforever.gatescore.core.WriteableUtil;

public class ToggleMenubar extends Widget{
	protected FrontDomain domain;
	
	public ToggleMenubar(FrontDomain domain) {
		super();
		this.domain = domain;
	}

	@Override
	public StatementList generateWidgetStatements() {
		List<Writeable> sList = new ArrayList<>();
		sList.add(new Statement(1000L,0,"<el-button-group>"));
		sList.add(new Statement(1200L,1,"<el-button :disabled=\"this.selectList.length==0 || this.selectList.length > 1\" size=\"mini\" type=\"success\" icon=\"el-icon-search\" @click=\"showViewDialog\">查看</el-button>"));
		if (!(this.domain instanceof org.javaforever.gatescore.core.FrontEnum)) {
			sList.add(new Statement(2000L,1,"<el-button :disabled=\"this.selectList.length==0\" size=\"mini\" type=\"primary\" icon=\"el-icon-star-off\" @click=\"activateAll"+this.domain.getCapFirstPlural()+"\">批激活</el-button>"));
			sList.add(new Statement(3000L,1,"<el-button :disabled=\"this.selectList.length==0\" size=\"mini\" type=\"primary\" icon=\"el-icon-delete\" @click=\"softDeleteAll"+this.domain.getCapFirstPlural()+"\">批软删除</el-button>"));
		}
		sList.add(new Statement(4000L,0,"</el-button-group>"));
		StatementList sl = WriteableUtil.merge(sList);
		sl.setSerial(this.serial);
		return sl;
	}

	@Override
	public StatementList generateWidgetScriptStatements() {
		try {
			List<Writeable> sList = new ArrayList<>();
			long serial = 0L;

			StatementList sl = WriteableUtil.merge(sList);
			sl.setSerial(this.serial);
			return sl;
		}catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

	@Override
	public boolean parse() {
		return true;
	}

	public FrontDomain getDomain() {
		return domain;
	}

	public void setDomain(FrontDomain domain) {
		this.domain = domain;
	}

}
